<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<title>${appname}-<c:if test="${!empty sessionScope._local_node_session}">${sessionScope._local_node_session.nodeName}-</c:if>${si:ctname("NET_TYPE",sessionScope._netType)}</title>
<%@ include file="/WEB-INF/view/common/css_js_ace.jsp"%>
<script type="text/javascript">

function search(form) {
	$(form).appendPagerParaStr();
	return true;
}
 
 
$(function(){
	$('.tipMe').tooltip({'placement':'top'});
	 if('${param.adapterType}'=='1'){
		 $('#adapterType_true').removeClass("active");
		 $('#adapterType_false').addClass("active");
	 }else{
		 $('#adapterType_true').addClass("active");
		 $('#adapterType_false').removeClass("active");
	 }
})

function adapterInfoList(val){
	 $('#adapterType').val(val);
 	if(val=='1'){
		$('#adapterType_true').removeClass("active");
		$('#adapterType_false').addClass("active");
 	}else{
 		$('#adapterType_true').addClass("active");
 	   	$('#adapterType_false').removeClass("active");
 	}
 	$('#searchForm').submit();
}
 

function lockedById(id) {
	ui.confirm('确认禁用该适配器?', function() {
		$.ajax({
			type : "POST",
			dataType : "json",
			cache : false,
			url : _ctx + "/registry/adapter_base_locked.do",
			data : {
				id : id
			},
			success : function(resp) {
				if (resp.status == '1') {
					ui.msg(resp.msg, 1);
					ui.go(_ctx + '/registry/adapter_base_list.do');
				} else {
					ui.msg(resp.msg, 0);
				}
			},
			error : function() {
				ui.msg('信息加载错误', 0);
			}
		});
	});
}


function unLockedById(id) {
	ui.confirm('确认启用该适配器?', function() {
		$.ajax({
			type : "POST",
			dataType : "json",
			cache : false,
			url : _ctx + "/registry/adapter_base_unlocked.do",
			data : {
				id : id
			},
			success : function(resp) {
				if (resp.status == '1') {
					ui.msg(resp.msg, 1);
					ui.go(_ctx + '/registry/adapter_base_list.do');
				} else {
					ui.msg(resp.msg, 0);
				}
			},
			error : function() {
				ui.msg('信息加载错误', 0);
			}
		});
	});
}



function adapterBaseGet(id){
	$.ajax({
		   type: "GET",
		   dataType:"html",
		   cache: false,
		   url: _ctx + "/registry/adapter_base_get.do",
		   data: {id:id},
		   success: function( content ){
			   $('#data').html( content ); 
			   $('#myModal').modal('show');
		   },
		   error:function(){
			   ui.msg('信息加载错误', 0);
		   }
	});
}


function menuSync(){
	$.ajax({
		   type: "POST",
		   dataType:"json",
		   cache: false,
		   url: _ctx + "/registry/adapter_base_sync.do",
		   success: function(resp){
			   if(resp.status == '1'){
				   ui.msg(resp.msg, 1);
				   ui.go(_ctx + '/registry/adapter_base_list.do');
			   }else{
				   ui.msg(resp.msg, 0);
			   }
		   },
		   error:function(){
			   ui.msg('信息加载错误', 0);
		   }
	});
}
</script>
</head>
<body>
	<%@ include file="/WEB-INF/view/common/topbar.jsp"%>
	<div class="main-container" id="main-container">
		<div class="main-container-inner">
			<%@ include file="/WEB-INF/view/common/sidebar.jsp"%>
			<div class="main-content">
				<div class="breadcrumbs" id="breadcrumbs">
					<ul class="breadcrumb">
						<li><i class="icon-home home-icon"></i> <a href="#">首页</a></li>
						<li><a href="#">注册管理</a></li>
						<li><a href="#">适配器管理</a></li>
						<li><a href="#">适配器注册</a></li>
						<li class="active">列表</li>
					</ul>
				</div>
				<div class="page-content">
					<div class="row">
						<div class="col-xs-12"> 
						
						
						<div class="widget-box">
				  				<div class="widget-header header-color-white">
									<div class="widget-toolbar no-border">
										<c:if test="${sessionScope._user_session.slAuthFlag eq 1 }">
										 <c:if test="${!netType}">   <button class="btn btn-primary btn-xs" onclick="return menuSync()" ><i class="icon-refresh bigger-110"></i> 同步到内网&nbsp;&nbsp;</button></c:if>									
										</c:if>
											<c:if test="${sessionScope._user_session.slAuthFlag eq 1 || sessionScope._user_session.slAuthFlag eq 2}">
											<c:if test="${!netType}"> <a class="btn btn-primary btn-xs" href="${ctx}/registry/adapter_base_add.do"><i class="icon-plus-sign icon-on-right"></i> 注册&nbsp;&nbsp;</a>
										    </c:if>
										</c:if>
										<a href="#" data-action="collapse">
											<i class="icon-chevron-up"></i>
										</a>
									</div>
								</div>
								
					  			<div class="widget-body">
									<div class="widget-main">
					  					<form  id="searchForm"  class="form-search"  action="${ctx}/registry/adapter_base_list.do" method="post" onsubmit="return search(this)">
						 					<input type="hidden" name="adapterType"  id="adapterType" value="${param.adapterType}"/>
						 					<div class="row">
											  <div class="col-xs-4">
													<div class="input-group"> 
													   <span class="input-group-addon">适配器名称：</span> 
														<input type="text" class="form-control"  name="adapterName" id="adapterName" value="${param.adapterName}"/>
													</div>
												</div>
											  <div class="col-xs-4">
												<div class="input-group"> 
												   <span class="input-group-addon">数据分类：</span> 
													<select class="form-control form-select" name="dataCode">
														<option value="">全部</option>
														<c:forEach var="vo" items="${dataCategory_list}">
														<option value="${vo.dataCode}" <c:if test="${vo.dataCode == param.dataCode }">selected</c:if>>${vo.dataName}</option>
														</c:forEach>
													</select>
												</div>
											  </div>
						 			 		  <div class="col-xs-4">
				                                    <div class="input-group">
															<span class="input-group-btn">
																<button type="submit" class="btn btn-purple btn-sm">
		                                                            <i class="icon-search icon-on-right bigger-110"></i>
		                                                                                                                                                                                          搜索
		                                                        </button>&nbsp;&nbsp;
																<a href="${ctx}/registry/adapter_base_list.do?adapterType=${param.adapterType}"
		                                                           class="btn btn-purple btn-sm">
		                                                            <i class="icon-refresh icon-on-right bigger-110"></i>
		                                                                                                                                                                                     清空
		                                                        </a>
															</span>
					                                    </div>
                                             </div>
                                            </div>
										</form>
									</div>
							</div>
						</div>
						<div class="hr hr12 hr-dotted"></div>
				             <ul class="nav nav-tabs " id="myTab">
								<li id="adapterType_true"><a href="javascript:void(0);"
									class="navbar-link" onclick="adapterInfoList('0');">全局适配器</a>
								</li>
								<li id="adapterType_false"><a href="javascript:void(0);"
									class="navbar-link" onclick="adapterInfoList('1');">局部适配器</a>
								</li>
							</ul>
							
							<div class="table-responsive">
								<table class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th class="center">序号</th>
											<th>适配器编码</th>
											<th>适配器名称</th>
											<th>适配器类型</th>
											<th>数据类型</th>
											<th>修改时间</th>
											<th>状态</th>
											<th>使用范围</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody>
										<c:forEach var="vo" items="${_data}" varStatus="sta">
											<tr>
												<td class="center">${sta.count}</td>
												<td>
													${vo.adapterCode }
												</td>
												<td>${vo.adapterName}</td>
												<td>${si:ctname("OBJECT_TYPE",vo.adapterType)}</td>
												<td>${si:dataName(vo.dataCode)}</td>
												<td>${si:fmtDate(vo.mtime)}</td>
												<td>
												  <c:if test="${vo.status=='0' }">启用</c:if>
												  <c:if test="${vo.status!='0' }">禁用</c:if>
												</td>
												<td>
												  <c:if test="${vo.adapterType=='0' }">
												    <span class='label label-info arrowed-in-right arrowed'>所有节点</span>
												  </c:if>
												   <c:if test="${vo.adapterType!='0' }">
												     <span class='label label-info arrowed-in-right arrowed'>
												     ${si:orgName(fn:substring(vo.adapterCode,0,6)) }及其管理范围内的节点
												     </span>
												   </c:if>
												</td>
												<td>
													<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons" >
														<a class="blue" href="javascript:void(0);" onclick="adapterBaseGet('${vo.id}')" title="查看">
															<i class="icon-zoom-in bigger-130"></i>
														</a>
														<c:if test="${sessionScope._user_session.slAuthFlag eq 2 }">
															<c:if test='${nodeAdmin eq 1 }'>
																<c:if test='${vo.adapterType eq 1 && vo.edit eq 1 }'>
																<c:if test="${!netType}"> 
																	<a class="green" href="${ctx}/registry/adapter_base_update/${vo.id}.do" title="修改"> <i class="icon-pencil bigger-130"></i> </a>
																	<c:choose>
																		<c:when test="${'1'==vo.status}">
																			<a class="green tipMe" href="javascript:void(0);" style="display: none;" title="启用" onclick="unLockedById('${vo.id}')"> 
																				<i class="icon-unlock bigger-130"></i> 
																			</a>
																		</c:when>
																		<c:otherwise>
																			<a class="red tipMe" href="javascript:void(0);" style="display: none;" title="禁用" onclick="lockedById('${vo.id}')"> 
																				<i class="icon-lock bigger-130"></i> 
																			</a>
																		</c:otherwise>
																	</c:choose>
																	</c:if>
																</c:if>
															</c:if>
														</c:if>
														<c:if test="${sessionScope._user_session.slAuthFlag eq 1   }">
															<c:if test='${nodeAdmin eq 1 }'>
															<c:if test="${!netType}"> 
																	<a class="green" href="${ctx}/registry/adapter_base_update/${vo.id}.do" title="修改"> <i class="icon-pencil bigger-130"></i> </a>
																	<c:choose>
																		<c:when test="${'1'==vo.status}">
																			<a class="green tipMe" href="javascript:void(0);" style="display: none;" title="启用" onclick="unLockedById('${vo.id}')"> 
																				<i class="icon-unlock bigger-130"></i> 
																			</a>
																		</c:when>
																		<c:otherwise>
																			<a class="red tipMe" href="javascript:void(0);" style="display: none;" title="禁用" onclick="lockedById('${vo.id}')"> 
																				<i class="icon-lock bigger-130"></i> 
																			</a>
																		</c:otherwise>
																	</c:choose>
																	</c:if>
															</c:if>
														</c:if>
													</div>
												</td>
												
											</tr>
										</c:forEach>
									</tbody>
								</table>
								<jsp:include page="/WEB-INF/view/common/pg.jsp">
									<jsp:param value="${ctx }/registry/adapter_info_list.do"
										name="url" />
									<jsp:param value="${_total}" name="total" />
									<jsp:param value="${_urlpara}" name="urlpara" />
								</jsp:include>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	
	<div id="myModal" class="modal fade" role="dialog"  tabindex="-1" aria-labelledby="查看" aria-hidden="false">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
		      </div>
				<div   id="data">
	  			</div>
				<div class="modal-footer wizard-actions">
					<button class="btn btn-danger btn-sm pull-left" data-dismiss="modal">
						<i class="icon-remove"></i>
						关闭
					</button>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
